////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//	MathFrustrum.h
//  MathLib
//
//  Created by Gregory Maks on 8/14/09.
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef MATH_FRUSTRUM_H
#define MATH_FRUSTRUM_H

#include "MathDefines.h"


// Predefinitions
struct Plane3D;
struct Rect3D;
struct QuadPoly3D;


struct Frustrum
{
public:
	Plane3D leftPlane;
	Plane3D rightPlane;
	Plane3D topPlane;
	Plane3D bottomPlane;
	Plane3D nearPlane;
	Plane3D farPlane;
	
	
public:
	void ctor();
	
	Frustrum();
	Frustrum(const Frustrum &aFrustrum);
	/// Calls ExtractPlanesFromViewProjectionMatrix() method
	Frustrum(Matrix4x4 &aMatrix, bool bNormalizePlanes);
	
	/// Extracts frustrum parameters from View/Projection matrix
	void ExtractPlanesFromViewProjectionMatrix (Matrix4x4 &matrix, bool bNormalizePlanes);

	/// Test if this rect is inside frustrum
	bool TestRect(Rect3D &aRect);
	bool TestQuad(QuadPoly3D &aQuad);
};

#endif //MATH_FRUSTRUM_H